#include "GameControl/GetEnemyPosition.hh"
#include "GameControl/IGetEnemyPosition.hh"
#include "characters/enemies/DemonEnemy.hh"
#include "characters/enemies/MuralEnemy.hh"
#include "characters/enemies/SpecimenEnemy.hh"
#include "characters/enemies/StatueEnemy.hh"
#include "characters/enemies/StudentEnemy.hh"
#include "items/item.hh"
#include <iostream>
#include <ctime>

GetEnemyPosition::GetEnemyPosition() : EnemyX(-1), EnemyY(-1), isAwake(false)
{
    std::srand(std::time(nullptr));
}

void GetEnemyPosition::spawnEnemy()
{
    EnemyX = std::rand() % 9;
    EnemyY = std::rand() % 9;
    isAwake = false;
}

bool GetEnemyPosition::checkEncounter(int playerX, int playerY)
{
    if (EnemyX == -1 || EnemyY == -1)
        return false;

    if (playerX == EnemyX && playerY == EnemyY && !isAwake)
    {
        isAwake = true;
        std::cout << "\n!!! Enemy come to life! Begin to attack!!!!\n\n";

        return true;
    }
    return false;
}

bool GetEnemyPosition::isActive() const
{
    return isAwake;
}

void GetEnemyPosition::reset()
{
    EnemyX = -1;
    EnemyY = -1;
    isAwake = false;
}